<template>
	<view>
		<zy-cell-item label="修改密码" @click.native="toPassword"></zy-cell-item>
		<zy-cell-item label="账号注销" @click.native="showDialogCancel"></zy-cell-item>
	</view>
</template>

<script>
	import RouteUtil from '@/main/common/RouteUtil.js'
	export default {
		data() {
			return {}
		},
		methods: {
			toPassword() {
				console.log("toPassword");
				RouteUtil.toUpdatePassword()
			},
			
			showDialogCancel() {
				uni.showModal({
					title: "操作确认",
					content: "注销后将保留7日数据，中途登录后自动取消注销状态，账号注销后该所有数据清空将无法恢复。",
					success: (res) => {
						if (res.confirm) {
							this.requestUnregist()
						}
					}
				})
			},

			async requestUnregist() {
				let res = await this.$common.post('/app/setup/writeOff');
				if (0 == res.code) {
					this.$common.showToast('注销成功')
					setTimeout(() => {
						LoginUtil.logout()
					}, 1000)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>